/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.managerServer.executors;


import protocol.*;
import server.managerServer.ServerWorker;

/**
 *
 * @author radu
 */
public class ExecutorPause extends Executor {

    MessagePauseReq msg;

    public ExecutorPause(Message _msg) {
        super(_msg);
        msg = (MessagePauseReq) _msg;
    }

    @Override
    public void doWork(ThreadWorker worker) {
        ServerWorker serverWorker = (ServerWorker) worker;
        long pollId = msg.getPollId();

        if (!serverWorker.pausePoll(pollId)) {
            serverWorker.sendMessage(new MessageError());
            return;
        }
        
        serverWorker.sendMessage(new MessagePauseRep(pollId));
    }

}
